From 825705b00e9b589f599f5bb45334cdfda2d1f97e Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 10 Jun 2023 13:18:32 -0600 Subject: [PATCH] drop support for filesystem access via garmin usb. (#1127) --- CMakeLists.txt | 2 - .../garmin_device_xml.cc | 0 .../garmin_device_xml.h | 0 garmin.cc | 23 +---------- jeeps/gpslibusb.cc | 41 ------------------- jeeps/gpsusbwin.cc | 37 ----------------- 6 files changed, 1 insertion(+), 102 deletions(-) rename garmin_device_xml.cc => deprecated/garmin_device_xml.cc (100%) rename garmin_device_xml.h => deprecated/garmin_device_xml.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cfa93ceb..ecdefb26d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,6 @@ set(RESOURCES gpsbabel.qrc) # MINIMAL_FMTS set(MINIMAL_FMTS garmin.cc - garmin_device_xml.cc garmin_tables.cc geo.cc gpx.cc @@ -207,7 +206,6 @@ set(HEADERS filter_vecs.h format.h formspec.h - garmin_device_xml.h garmin_fit.h garmin_fs.h garmin_gpi.h diff --git a/garmin_device_xml.cc b/deprecated/garmin_device_xml.cc similarity index 100% rename from garmin_device_xml.cc rename to deprecated/garmin_device_xml.cc diff --git a/garmin_device_xml.h b/deprecated/garmin_device_xml.h similarity index 100% rename from garmin_device_xml.h rename to deprecated/garmin_device_xml.h diff --git a/garmin.cc b/garmin.cc index 52e74530b..97ccdc385 100644 --- a/garmin.cc +++ b/garmin.cc @@ -22,14 +22,12 @@ #include // for assert #include // for INT_MAX #include // for atan2, floor, sqrt -#include // for setjmp #include // for fprintf, fflush, snprintf, snprintf #include // for strtol #include // for memcpy, strlen, strncpy, strchr #include // for time_t #include // for QByteArray -#include // for QChar #include // for QRegularExpression #include // for QString #include // for QTextCodec @@ -38,9 +36,7 @@ #include // for qPrintable, foreach #include "defs.h" -#include "format.h" // for Format #include "formspec.h" // for FormatSpecificDataList -#include "garmin_device_xml.h" // for gdx_get_info, gdx_info, gdx_file, gdx_jmp_buf #include "garmin_fs.h" // for garmin_fs_garmin_after_read, garmin_fs_garmin_before_write #include "garmin_tables.h" // for gt_find_icon_number_from_desc, PCX, gt_find_desc_from_icon_number #include "geocache.h" // for Geocache, Geocache::type_t, Geocache... @@ -55,7 +51,6 @@ #include "jeeps/gpsserial.h" // for DEFAULT_BAUD #include "jeeps/gpsutil.h" // for GPS_User, GPS_Enable_Diagnose, GPS_E... #include "src/core/datetime.h" // for DateTime -#include "vecs.h" // for Vecs #define MYNAME "GARMIN" @@ -83,8 +78,6 @@ static int categorybits; static int receiver_must_upper = 1; static QTextCodec* codec{nullptr}; -static Vecs::fmtinfo_t gpx_vec; - #define MILITANT_VALID_WAYPT_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" /* Technically, even this is a little loose as spaces aren't allowed */ @@ -393,16 +386,7 @@ rw_init(const QString& fname) static void rd_init(const QString& fname) { - if (setjmp(gdx_jmp_buf)) { - const gdx_info* gi = gdx_get_info(); - // FIXME: dynamic not implemented. - gpx_vec = Vecs::Instance().find_vec("gpx"); - Vecs::prepare_format(gpx_vec); - gpx_vec->rd_init(gi->from_device.canon); - } else { - gpx_vec = Vecs::fmtinfo_t(); - rw_init(fname); - } + rw_init(fname); } static void @@ -781,11 +765,6 @@ pvt_read(posn_status* posn_status) static void data_read() { - if (gpx_vec) { - gpx_vec->read(); - return; - } - if (poweroff) { return; } diff --git a/jeeps/gpslibusb.cc b/jeeps/gpslibusb.cc index 2235271f4..752379d72 100644 --- a/jeeps/gpslibusb.cc +++ b/jeeps/gpslibusb.cc @@ -37,7 +37,6 @@ #include "jeeps/garminusb.h" #include "jeeps/gpsdevice.h" #include "jeeps/gpsusbcommon.h" -#include "garmin_device_xml.h" #define GARMIN_VID 0x91e @@ -68,7 +67,6 @@ static unsigned char gusb_bulk_in_ep; static bool libusb_successfully_initialized{false}; static libusb_device_handle* udev{nullptr}; static int garmin_usb_scan(libusb_unit_data*, int); -static const gdx_info* gdx; static int gusb_libusb_get(garmin_usb_packet* ibuf, size_t sz); static int gusb_libusb_get_bulk(garmin_usb_packet* ibuf, size_t sz); @@ -83,33 +81,6 @@ static gusb_llops_t libusb_llops = { 0 }; -#if __linux__ -static -char** os_get_garmin_mountpoints() -{ - // Hacked for testing. - return nullptr; -} -#elif __APPLE__ -// In fantasy land, we'd query iokit for enumerated devices of the Garmin -// vendor ID and match that against the mounted device table. In practical -// matters, that's crazy complex and this is where the devices seems to always -// get mounted... -char** os_get_garmin_mountpoints() -{ - char** dlist = (char**) xcalloc(2, sizeof *dlist); - dlist[0] = xstrdup("/Volumes/GARMIN"); - dlist[1] = nullptr; - return dlist; -} -#else -char** os_get_garmin_mountpoints() -{ - return nullptr; -} -#endif - - static int gusb_libusb_send(const garmin_usb_packet* opkt, size_t sz) { @@ -504,18 +475,6 @@ int garmin_usb_scan(libusb_unit_data* lud, int req_unit_number) } if (0 == found_devices) { - /* It's time for Plan B. The user told us to use - * Garmin Protocol in device "usb:" but it's possible - * that they're talking to one of the dozens of models - * that is wants to read and write GPX files on a - * mounted drive. Try that now. - */ - char** dlist = os_get_garmin_mountpoints(); - gdx = gdx_find_file(dlist); - if (gdx != nullptr) { - return 1; - } - /* Plan C. */ fatal("Found no Garmin USB devices.\n"); } else if (req_unit_number >= found_devices) { fatal("usb unit number(%d) too high.\n" diff --git a/jeeps/gpsusbwin.cc b/jeeps/gpsusbwin.cc index 4b5f3e25a..5cec69609 100644 --- a/jeeps/gpsusbwin.cc +++ b/jeeps/gpsusbwin.cc @@ -27,7 +27,6 @@ #include #include -#include "garmin_device_xml.h" #include "jeeps/garminusb.h" #include "jeeps/gps.h" #include "jeeps/gpsapp.h" @@ -55,7 +54,6 @@ typedef struct { static HANDLE usb_handle = INVALID_HANDLE_VALUE; static int usb_tx_packet_size ; -static const gdx_info* gdx; static int gusb_win_close(gpsdevh* /* handle */, bool /* exit_lib */) @@ -185,30 +183,6 @@ HANDLE garmin_usb_start(HDEVINFO hdevinfo, SP_DEVICE_INTERFACE_DATA* infodata) return usb_handle; } - -static char** get_garmin_mountpoints(void) -{ -#define BUFSIZE 512 - char szTemp[MAX_PATH]; - char* p = szTemp; - char** dlist = (char **) xmalloc(sizeof(*dlist)); - - dlist[0] = NULL; - - if (GetLogicalDriveStringsA(BUFSIZE-1, szTemp)) { - int i = 0; - while (*p) { - dlist = (char **) xrealloc(dlist, sizeof(*dlist) * (++i + 1)); - // fprintf(stderr, "Found: %d, %s\n", i, p); - dlist[i-1] = xstrdup(p); - dlist[i] = NULL; - while (*p++); - } - } - - return dlist; -} - /* * Main entry point from the upper layer. Walk the device tree, find our * device, and light it up. @@ -251,17 +225,6 @@ gusb_init(const char* pname, gpsdevh** dh) if (!SetupDiEnumDeviceInterfaces(hdevinfo, NULL, &GARMIN_GUID, req_unit_number, &devinterface)) { - // If there were zero matches, we may be trying to talk to a "GPX Mode" device. - - - char** dlist = get_garmin_mountpoints(); - gdx = gdx_find_file(dlist); - if (gdx) { - return 1; - } - - - // Plan C. GPS_Serial_Error("SetupDiEnumDeviceInterfaces"); warning("Is the Garmin USB unit number %d powered up and connected?\nIs it really a USB unit? If it's serial, don't choose USB, choose serial.\nAre the Garmin USB drivers installed and functioning with other programs?\nIs it a storage based device like Nuvi, CO, or OR?\n If so, send GPX files to it, don't use this module.\n", un); return 0; -- 2.30.2